package flychess.view;

import flychess.data.GameMap;
import flychess.entity.Player;

public class DisplayMapAdvanced extends DisplayMap{
    public DisplayMapAdvanced(GameMap map) {
        this.gMap = map;
    }

    @Override
    public void showMap(Player player1, Player player2) {
        // 第1横行
        printInterval(0, 9, player1, player2);
        printSpaces(2);
        printInterval(20, 29, player1, player2);
        System.out.println();
        // 第2横行
        printSingle(103, player1, player2);
        printSpaces(8);
        printSingle(9, player1, player2);
        printSpaces(2);
        printSingle(19, player1, player2);
        printSpaces(8);
        printSingle(29, player1, player2);
        System.out.println();
        // 第3横行
        printSingle(102, player1, player2);
        printSpaces(8);
        printSingle(10, player1, player2);
        printSpaces(2);
        printSingle(18, player1, player2);
        printSpaces(8);
        printSingle(30, player1, player2);
        System.out.println();
        // 第4横行
        printSingle(101, player1, player2);
        printSpaces(8);
        printSingle(11, player1, player2);
        printSpaces(2);
        printSingle(17, player1, player2);
        printSpaces(8);
        printSingle(31, player1, player2);
        System.out.println();
        // 第5横行
        printSingle(100, player1, player2);
        printSpaces(8);
        printSingle(12, player1, player2);
        printSpaces(2);
        printSingle(16, player1, player2);
        printSpaces(8);
        printSingle(32, player1, player2);
        System.out.println();
        // 第6横行
        printSingle(99, player1, player2);
        printSpaces(8);
        printInterval(13, 16, player1, player2);
        printSpaces(8);
        printSingle(33, player1, player2);
        System.out.println();
        // 第7横行
        printIntervalInv(98, 93, player1, player2);
        printSpaces(8);
        printIntervalInv(39, 34, player1, player2);
        System.out.println();
        // 第8横行
        printSpaces(6);
        printSingle(92, player1, player2);
        printSpaces(8);
        printSingle(40, player1, player2);
        printSpaces(6);
        System.out.println();
        // 第6横行
        printInterval(86, 92, player1, player2);
        printSpaces(8);
        printInterval(41, 47, player1, player2);
        System.out.println();
        // 第10横行
        printSingle(85, player1, player2);
        printSpaces(8);
        printIntervalInv(67, 65, player1, player2);
        printSpaces(8);
        printSingle(47, player1, player2);
        System.out.println();
        // 第11横行
        printSingle(84, player1, player2);
        printSpaces(8);
        printSingle(68, player1, player2);
        printSpaces(2);
        printSingle(64, player1, player2);
        printSpaces(8);
        printSingle(48, player1, player2);
        System.out.println();
        // 第12横行
        printSingle(83, player1, player2);
        printSpaces(8);
        printSingle(69, player1, player2);
        printSpaces(2);
        printSingle(63, player1, player2);
        printSpaces(8);
        printSingle(49, player1, player2);
        System.out.println();
        // 第13横行
        printSingle(82, player1, player2);
        printSpaces(8);
        printSingle(70, player1, player2);
        printSpaces(2);
        printSingle(62, player1, player2);
        printSpaces(8);
        printSingle(50, player1, player2);
        System.out.println();
        // 第14横行
        printSingle(81, player1, player2);
        printSpaces(8);
        printSingle(71, player1, player2);
        printSpaces(2);
        printSingle(61, player1, player2);
        printSpaces(8);
        printSingle(51, player1, player2);
        System.out.println();
        // 第15横行
        printIntervalInv(80, 72, player1, player2);
        printSpaces(2);
        printIntervalInv(60, 52, player1, player2);
        System.out.println();
    }

    public void printSingle(int i, Player player1, Player player2) {
        System.out.print(getGraph(this.gMap.map[i], i, player1, player2));
    }

    public void printInterval(int from, int to, Player player1, Player player2) {
        for (int i = from; i < to; i++) System.out.print(getGraph(this.gMap.map[i], i, player1, player2));
    }

    public void printSpaces(int cnt) {
        for (int i = 1; i < cnt; i++) {
            System.out.print("　");
        }
    }

    // 反向输出
    public void printIntervalInv(int from, int to, Player player1, Player player2) {
        for (int i = from; i >= to; i--) {
            System.out.print(getGraph(this.gMap.map[i], i, player1, player2));
        }
    }
}
